﻿<Window x:Class="TeamProjectManager.Modules.WorkItemConfiguration.ComparisonResultViewerDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:w="clr-namespace:TeamProjectManager.Modules.WorkItemConfiguration"
        Title="Comparison Result Details"
        WindowStartupLocation="CenterOwner"
        ShowInTaskbar="False"
        Height="768" Width="1024">
    <Window.Resources>
        <w:ComparisonStatusConverter x:Key="comparisonStatusConverter" />
        <w:WorkItemConfigurationItemTypeConverter x:Key="workItemConfigurationItemTypeConverter" />
    </Window.Resources>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" MinWidth="150" />
                <ColumnDefinition Width="*" MinWidth="150" />
                <ColumnDefinition Width="*" MinWidth="150" />
            </Grid.ColumnDefinitions>

            <GroupBox Grid.Column="0" Header="Sources">
                <DataGrid ItemsSource="{Binding Path=WorkItemConfigurationResults}" x:Name="workItemConfigurationResultsDataGrid" SelectionChanged="workItemConfigurationResultsDataGrid_SelectionChanged" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Source" Binding="{Binding Path=Source.Name}" />
                        <DataGridTextColumn Header="Match" Binding="{Binding Path=PercentMatch, StringFormat='{}{0:0%}'}" />
                    </DataGrid.Columns>
                </DataGrid>
            </GroupBox>

            <GroupBox Grid.Column="1" Header="Items" Margin="5,0,0,0">
                <DataGrid ItemsSource="{Binding ElementName=workItemConfigurationResultsDataGrid, Path=SelectedItem.ItemResults}" AutoGenerateColumns="False" IsReadOnly="True" x:Name="workItemConfigurationItemResultsDataGrid" SelectionChanged="workItemConfigurationItemResultsDataGrid_SelectionChanged" MouseDoubleClick="workItemConfigurationItemResultsDataGrid_MouseDoubleClick" SelectionMode="Single">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Status" Binding="{Binding Path=Status, Converter={StaticResource comparisonStatusConverter}, ConverterParameter=short}" TextBlock.TextAlignment="Center" />
                        <DataGridTextColumn Header="Item" Binding="{Binding Path=ItemName}" />
                        <DataGridTextColumn Header="Match" Binding="{Binding Path=PercentMatch, StringFormat='{}{0:0%}'}" />
                    </DataGrid.Columns>
                </DataGrid>
            </GroupBox>

            <GroupBox Grid.Column="2" Header="Item Details" Margin="5,0,0,0">
                <Grid Grid.Column="2" DataContext="{Binding ElementName=workItemConfigurationItemResultsDataGrid, Path=SelectedItem}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Label Grid.Row="0" Grid.Column="0" Content="Name" />
                    <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=ItemName, Mode=OneWay}" IsReadOnly="True" Margin="5,5,0,0" />

                    <Label Grid.Row="1" Grid.Column="0" Content="Type" />
                    <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=Type, Mode=OneWay, Converter={StaticResource workItemConfigurationItemTypeConverter}}" IsReadOnly="True" Margin="5,5,0,0" />

                    <Label Grid.Row="2" Grid.Column="0" Content="Status" />
                    <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=Status, Mode=OneWay, Converter={StaticResource comparisonStatusConverter}}" IsReadOnly="True" Margin="5,5,0,0" />

                    <Label Grid.Row="3" Grid.Column="0" Content="Match" Margin="0,5,0,0" />
                    <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=PercentMatch, Mode=OneWay, StringFormat='{}{0:0%}'}" IsReadOnly="True" Margin="5,5,0,0" />

                    <DataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding Path=PartResults}" Margin="0,5,0,0" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single">
                        <DataGrid.Columns>
                            <DataGridCheckBoxColumn Header="Equal" Binding="{Binding Path=Status, Converter={StaticResource comparisonStatusConverter}, ConverterParameter=bool, Mode=OneWay}" />
                            <DataGridTextColumn Header="Name" Binding="{Binding Path=PartName, Mode=OneWay}" />
                            <DataGridTextColumn Header="Relative Size" Binding="{Binding Path=RelativeSize, StringFormat='{}{0:0%}', Mode=OneWay}" />
                        </DataGrid.Columns>
                    </DataGrid>

                    <Button Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Content="Compare In Diff Tool" x:Name="compareInDiffToolButton" Click="compareInDiffToolButton_Click" HorizontalAlignment="Stretch" Margin="0,5,0,0" />
                </Grid>
            </GroupBox>
        </Grid>

        <Grid Grid.Row="1" Margin="0,5,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" Orientation="Horizontal">
                <Label Content="Diff Tool:" />
                <ComboBox x:Name="diffToolsComboBox" DisplayMemberPath="Name" Margin="5,0,0,0" />
            </StackPanel>
            <Button Grid.Column="1" Content="OK" IsDefault="True" IsCancel="True"  Width="75" x:Name="okButton" Click="okButton_Click" Margin="5,0,0,0" />
        </Grid>

    </Grid>
</Window>